package com.imooc.bilibili.service;

import com.imooc.bilibili.dao.UserCoinDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class UserCoinService {

    @Autowired
    private UserCoinDao userCoinDao;

    /**
     * 查询用户的硬币总数
     * @param userId
     * @return
     */
    public Long getAmountByUserId(Long userId) {
        return userCoinDao.getAmountByUserId(userId);
    }

    /**
     * 更新用户硬币总数
     * @param userId
     * @param amount
     */
    public void updateUserCoinAmount(Long userId, Long amount) {
        Date updateTime = new Date();
        userCoinDao.updateUserCoinAmount(userId,amount,updateTime);
    }
}
